#include <cstdio>

const int N = 2e5 + 5;
int n, k, p, rt, tot, ans;

struct Node {
  int fa, ch[2], siz, val, cnt;
} tr[N];

inline void pushup(int x) {
  if (x) {
    tr[x].siz = tr[x].cnt;
    if (tr[x].ch[0]) tr[x].siz += tr[tr[x].ch[0]].siz;
    if (tr[x].ch[1]) tr[x].siz += tr[tr[x].ch[1]].siz;
  }
}

inline bool iden(int x) { return tr[tr[x].fa].ch[1] == x; }

inline void rotate(int x) {
  bool xtofa = iden(x);
  int fa = tr[x].fa, ffa = tr[fa].fa, son = tr[x].ch[!xtofa];
  if (ffa) tr[ffa].ch[iden(fa)] = x;
  tr[x].ch[!xtofa] = fa;
  tr[fa].fa = x;
  tr[fa].ch[xtofa] = son;
  tr[x].fa = ffa;
  if (son) tr[son].fa = fa;
  pushup(fa);
  pushup(x);
}

inline void splay(int x) {
  for (int fa; (fa = tr[x].fa); rotate(x)) {
    if (tr[fa].fa) rotate(iden(fa) == iden(x) ? fa : x);
  }
  rt = x;
}

inline void insert(int val) {
  if (!rt)
    return tr[rt = ++tot].val = val, tr[tot].cnt = 1, tr[tot].siz = 1, void();
  int x = rt, fa = 0;
  while (true) {
    if (tr[x].val == val) return ++tr[x].cnt, pushup(x), pushup(fa), splay(x);
    fa = x, x = tr[x].ch[val > tr[x].val];
    if (!x) {
      return tr[++tot].fa = fa, tr[tot].cnt = 1, tr[tot].val = val, pushup(tot),
             tr[fa].ch[val > tr[fa].val] = tot, pushup(fa), splay(tot);
    }
  }
}

inline int rank(int k) {
  int x = rt;
  while (x) {
    if (tr[tr[x].ch[1]].siz >= k) x = tr[x].ch[1];
    else if (tr[tr[x].ch[1]].siz < k && k <= tr[tr[x].ch[1]].siz + tr[x].cnt) {
      break;
    } else
      k -= tr[tr[x].ch[1]].siz + tr[x].cnt, x = tr[x].ch[0];
  }
  if (x) splay(x);
  return tr[x].val;
}

inline void earase(int val) {
  int x = rt, fa = 0;
  while (x) {
    if (tr[x].val == val) {
      if (tr[x].cnt > 1) return tr[x].cnt--, tr[x].siz--, pushup(fa), splay(x);
      else {
        splay(x);
        if (!tr[x].ch[0] && !tr[x].ch[1]) return rt = 0, void();
        if (!tr[x].ch[0]) return rt = tr[x].ch[1], tr[rt].fa = 0, void();
        if (!tr[x].ch[1]) return rt = tr[x].ch[0], tr[rt].fa = 0, void();
        int tmp = tr[x].ch[0];
        while (tr[tmp].ch[1]) tmp = tr[tmp].ch[1];
        splay(tmp);
        tr[tmp].ch[1] = tr[x].ch[1];
        tr[tr[x].ch[1]].fa = tmp;
        pushup(tmp);
        return;
      }
    } else if (x < tr[x].val)
      x = tr[x].ch[0];
    else
      x = tr[x].ch[1];
  }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("queue.in", "r", stdin);
  freopen("queue.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &k, &p);
  for (int i = 1, opt, x; i <= n; ++i) {
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d", &x);
      insert(p ? x ^ ans : x);
    } else {
      printf("%d\n", ans = rank(k));
      earase(ans);
    }
  }
  return 0;
}